/*
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-30 10:30:10
 * @LastEditTime: 2019-08-30 14:22:36
 * @LastEditors: Please set LastEditors
 */
/*
 * @lc app=leetcode.cn id=22 lang=javascript
 *
 * [22] 括号生成
 *
 * https://leetcode-cn.com/problems/generate-parentheses/description/
 *
 * algorithms
 * Medium (71.54%)
 * Likes:    494
 * Dislikes: 0
 * Total Accepted:    37.8K
 * Total Submissions: 52.9K
 * Testcase Example:  '3'
 *
 * 给出 n 代表生成括号的对数，请你写出一个函数，使其能够生成所有可能的并且有效的括号组合。
 * 
 * 例如，给出 n = 3，生成结果为：
 * 
 * [
 * ⁠ "((()))",
 * ⁠ "(()())",
 * ⁠ "(())()",
 * ⁠ "()(())",
 * ⁠ "()()()"
 * ]
 * 
 * 
 */
/**
 * @param {number} n
 * @return {string[]}
 */

//  回溯法
// var generateParenthesis = function(n) {
//     const ans = []
//     const backStack = function(ans,cur,open,close){
//         if(cur.length == n*2){
//             ans.push(cur)
//             return
//         }
//         if(open < n){
//             backStack(ans,cur+'(',open+1,close)
//         }
//         if(open > close){
//             backStack(ans,cur+')',open,close+1)

//         }
//     }
//     backStack(ans,'',0,0)
//     return ans
// };


// 闭合法
var generateParenthesis = function(n){
    if(n == 1)return ["()"]
    if(n == 0)return []
    const ans = []

    const backStack = function(ans,cur,n){
        const n = n - 1
        if(n = 1){
            ans.push()
        }
    }

}

